<template>
  <el-dropdown trigger="click" class="international" style="margin:0 8px" @command="changeExportType">
    <el-button size="small">
      {{ t('message.components.export') }}
      <el-icon class="el-icon--right">
        <ArrowDown />
      </el-icon>
    </el-button>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item v-for="item in options" :key="item.value" :command="item">
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts" name="slExport">
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { ArrowDown } from '@element-plus/icons-vue'

const { t } = useI18n()

interface OptionItem {
  value: number
  label: string
}

const defaultValue = ref('')
const options = ref<OptionItem[]>([
  {
    value: 1,
    label: t('message.components.exportAllColumns')
  },
  {
    value: 2,
    label: t('message.components.exportCurrentColumns')
  }
])

const emit = defineEmits<{
  (e: 'buttonClick', value: number): void
}>()

const changeExportType = (item: OptionItem) => {
  emit('buttonClick', item.value)
}
</script>

<style scoped>
</style>
